package com.wwc.business.controller;

import com.wwc.business.controller.dto.station.StationDeleteDTO;
import com.wwc.business.controller.dto.station.StationInsertDTO;
import com.wwc.business.controller.dto.station.StationSelectListDTO;
import com.wwc.business.controller.dto.station.StationUpdateDTO;
import com.wwc.business.controller.vo.StationSelectListVO;
import com.wwc.business.service.IStationService;
import com.wwc.common.response.CommonResponse;
import com.wwc.common.response.PageResponse;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 车站 Controller
 */
@RestController
@RequestMapping("/admin/station")
public class StationController{
	@Resource
	private IStationService stationService;

	/**
	 * 新增车站
	 */
	@PostMapping("/insert")
	public CommonResponse<?> insert(@Valid @RequestBody StationInsertDTO stationInsertDTO){
		stationService.insert(stationInsertDTO);
		return new CommonResponse<>();
	}

	/**
	 * 更新车站
	 */
	@PostMapping("/update")
	public CommonResponse<?> update(@Valid @RequestBody StationUpdateDTO stationUpdateDTO){
		stationService.update(stationUpdateDTO);
		return new CommonResponse<>();
	}

	/**
	 * 删除车站
	 */
	@PostMapping("/delete")
	public CommonResponse<?> delete(@Valid @RequestBody StationDeleteDTO stationDeleteDTO){
		stationService.delete(stationDeleteDTO);
		return new CommonResponse<>();
	}

	/**
	 * 查询车站列表
	 */
	@GetMapping("/select-list")
	public CommonResponse<List<StationSelectListVO>> selectList(){
		List<StationSelectListVO> stationSelectListVOList = stationService.selectList();
		return new CommonResponse<>(stationSelectListVOList);
	}

	/**
	 * 查询车站分页列表
	 */
	@GetMapping("/select-list-page")
	public CommonResponse<PageResponse<StationSelectListVO>> selectListPage(@Valid StationSelectListDTO stationSelectListDTO){
		PageResponse<StationSelectListVO> pageResponse = stationService.selectListPage(stationSelectListDTO);
		return new CommonResponse<>(pageResponse);
	}
}
